package com.splic.product.service.impl;

import java.util.Date;
import java.util.List;
import com.splic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.splic.product.mapper.VoiceProviderMapper;
import com.splic.product.domain.VoiceProvider;
import com.splic.product.service.VoiceProviderService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 语音厂商Service业务层处理
 * 
 * @author singe
 * @date 2023-08-16
 */
@Service
public class VoiceProviderServiceImpl implements VoiceProviderService
{
    @Autowired
    private VoiceProviderMapper voiceProviderMapper;

    /**
     * 查询语音厂商
     * 
     * @param id 语音厂商主键
     * @return 语音厂商
     */
    @Override
    public VoiceProvider selectVoiceProviderById(Long id)
    {
        return voiceProviderMapper.selectVoiceProviderById(id);
    }

    /**
     * 查询语音厂商列表
     * 
     * @param voiceProvider 语音厂商
     * @return 语音厂商
     */
    @Override
    public List<VoiceProvider> selectPageList(VoiceProvider voiceProvider)
    {
        return voiceProviderMapper.selectVoiceProviderList(voiceProvider);
    }

    /**
     * 查询有效语音厂商列表
     *
     * @param voiceProvider 语音厂商
     * @return 语音厂商
     */
    @Override
    public List<VoiceProvider> selectEffictList()
    {
        return voiceProviderMapper.selectEffictList();
    }

    /**
     * 查询语音厂商列表
     *
     * @param voiceProvider 语音厂商
     * @return 语音厂商
     */
    @Override
    public List<VoiceProvider> selectVoiceProviderList(VoiceProvider voiceProvider)
    {
        return voiceProviderMapper.selectVoiceProviderList(voiceProvider);
    }

    /**
     * 新增语音厂商
     * 
     * @param voiceProvider 语音厂商
     * @return 结果
     */
    @Override
    public int insert(VoiceProvider voiceProvider)
    {
        voiceProvider.setCreateTime(DateUtils.getNowDate());
        return voiceProviderMapper.insert(voiceProvider);
    }

    /**
     * 修改语音厂商
     * 
     * @param voiceProvider 语音厂商
     * @return 结果
     */
    @Override
    public int update(VoiceProvider voiceProvider)
    {
        voiceProvider.setUpdateTime(DateUtils.getNowDate());
        return voiceProviderMapper.update(voiceProvider);
    }


    /**
     * 删除语音厂商信息
     * 
     * @param id 语音厂商主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id)
    {
        return voiceProviderMapper.deleteById(id);
    }
    /**
     * 修改语音厂商
     *
     * @param voiceProvider 语音厂商信息
     * @return 结果
     */
    @Override
    @Transactional
    public int saveOrUpdate(VoiceProvider voiceProvider)
    {
        if(voiceProvider.getId() != null){
            voiceProvider.setUpdateTime(new Date());
            return voiceProviderMapper.update(voiceProvider);
        }else{
            voiceProvider.setCreateTime(new Date());
            return voiceProviderMapper.insert(voiceProvider);
        }
    }
}
